local joyex__kuanggu = fk.CreateSkill {

  name = "joyex__kuanggu",

  tags = {  },

}



joyex__kuanggu:addEffect(fk.Damage, {
  name = "joyex__kuanggu",
  anim_type = "drawcard",
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(joyex__kuanggu.name) and target == player
  end,
  on_trigger = function(self, event, target, player, data)
    self.cancel_cost = false
    for i = 1, data.damage do
      self:doCost(event, target, player, data)
      if event:getCostData(self) == "Cancel" or player.dead then break end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local choices = {"draw1", "Cancel"}
    if player:isWounded() then
      table.insert(choices, 2, "recover")
    end
    event:setCostData(self, room:askForChoice(player), choices, joyex__kuanggu.name)
    return event:getCostData(self) ~= "Cancel"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event:getCostData(self) == "recover" then
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = joyex__kuanggu.name
      })
    elseif event:getCostData(self) == "draw1" then
      player:drawCards(1, joyex__kuanggu.name)
    end
  end,
})

return joyex__kuanggu